package tpenchere.ui.contents;

import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.GridLayout;

import javax.swing.JMenuBar;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import javax.swing.JToolBar;

import org.jdesktop.application.ResourceMap;
import org.jdesktop.swingx.JXStatusBar;

import tpenchere.application.MainApplication;
import tpenchere.controllers.ControllerInterface;
import tpenchere.controllers.LoginController;
import tpenchere.ui.AbstractView;

import java.awt.Dimension;
import java.util.List;

import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.factories.FormFactory;
import javax.swing.JSplitPane;

public class LoginWindow extends AbstractView {
	private final ResourceMap resourceMap = MainApplication.getApplication().getContext().getResourceMap(this.getClass());
	private LoginController controller;
	private JTextField login;
	private JPasswordField password;
	
	public LoginWindow() {
		controller = new LoginController(this);
		setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("default:grow"),},
			new RowSpec[] {
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("default:grow"),}));
		
		JLabel lblIdentifiant = new JLabel("Identifiant");
		add(lblIdentifiant, "2, 2, right, default");
		
		login = new JTextField();
		login.setSize(new Dimension(100, 20));
		login.setMinimumSize(new Dimension(100, 20));
		login.setPreferredSize(new Dimension(100, 20));
		login.setMaximumSize(new Dimension(100, 20));
		add(login, "4, 2, left, default");
		
		JLabel lblMotDePasse = new JLabel("Mot de passe");
		add(lblMotDePasse, "2, 4, right, default");
		
		password = new JPasswordField();
		password.setPreferredSize(new Dimension(100, 20));
		password.setMinimumSize(new Dimension(100, 20));
		password.setSize(new Dimension(100, 20));
		password.setMaximumSize(new Dimension(100, 20));
		add(password, "4, 4, left, default");
		
		JPanel panel = new JPanel();
		add(panel, "4, 6, fill, fill");
		panel.setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,},
			new RowSpec[] {
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,}));
		
		JButton btnConnexion = new JButton(controller.getActionMap().get("view.login.button.connection"));
		panel.add(btnConnexion, "2, 2");
		
		JButton btnRegister = new JButton(controller.getActionMap().get("view.login.button.register"));
		panel.add(btnRegister, "4, 2");
		
		setVisible(true);
	}
	@Override
	public ControllerInterface getController() {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public JMenuBar getMenuBar() {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public JXStatusBar getStatusBar() {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public List<JToolBar> getToolbars() {
		// TODO Auto-generated method stub
		return null;
	}
	public JTextField getLogin() {
		return login;
	}
	public void setLogin(JTextField login) {
		this.login = login;
	}
	public JPasswordField getPassword() {
		return password;
	}
	public void setPassword(JPasswordField password) {
		this.password = password;
	}
}
